package com.ruoyi.monitor.domain;

import java.util.Date;
import java.util.Objects;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.monitor.utils.Common.Constant;

/**
 * 污染物对象 pollutant
 * 
 * @author xzx
 * @date 2023-01-04
 */
@TableName("hour_pollutant")
public class Pollutant extends BaseEntity implements Comparable
{
    private static final long serialVersionUID = 1L;

    /** $column.columnComment */
    @Excel(name = "编号",cellType = Excel.ColumnType.NUMERIC,prompt = "编号")
    @TableId(value = "id",type = IdType.AUTO)
    private Integer id;

    /** $column.columnComment */
    @Excel(name = "primary_pollutant")
    @TableField("primary_pollutant")
    private String primary_pollutant;

    /** $column.columnComment */
    @Excel(name = "空气污染指数(AQI)",cellType = Excel.ColumnType.NUMERIC)
    private Float aqi;

    /** $column.columnComment */
    @Excel(name = "PM10",cellType = Excel.ColumnType.NUMERIC)
    private Float pm10;

    /** $column.columnComment */
    @Excel(name = "O38h",cellType = Excel.ColumnType.NUMERIC)
    @TableField("o38h")
    private Float o38h;

    /** $column.columnComment */
    @Excel(name = "城市",cellType =  Excel.ColumnType.STRING)
    private String area;

    /** $column.columnComment */
    @Excel(name = "一氧化碳",cellType = Excel.ColumnType.NUMERIC)
    private Float co;

    /** $column.columnComment */
    @Excel(name = "O3",cellType = Excel.ColumnType.NUMERIC)
    private Float o3;

    /** $column.columnComment */
    @Excel(name = "城市代码",cellType = Excel.ColumnType.STRING)
    @TableField("area_code")
    private String areaCode;

    /** $column.columnComment */
    @Excel(name = "二氧化硫",cellType = Excel.ColumnType.NUMERIC)
    private Float so2;

    /** $column.columnComment */
    @Excel(name = "二氧化氮",cellType = Excel.ColumnType.NUMERIC)
    private Float no2;

    /** $column.columnComment */
    @Excel(name = "空气等级",cellType = Excel.ColumnType.STRING)
    private String quality;

    /** $column.columnComment */
    @Excel(name = "空气质量排名",cellType = Excel.ColumnType.NUMERIC)
    private Integer num;

    /** $column.columnComment */
    @Excel(name = "时间",dateFormat = "yyyy-MM-dd",readConverterExp = "$column.readConverterExp()")
    @JsonFormat(timezone = "GMT+8",pattern="yyyy-MM-dd HH:mm:ss")
    private Date ct;

    /** $column.columnComment */
    @Excel(name = "PM25",cellType = Excel.ColumnType.NUMERIC)
    @TableField("pm25")
    private Float pm25;

    /**
     * search_value,create_by,create_time,update_by,update_time,remark,params
     * @param id
     */
    @TableField(exist = false)
    private String searchValue;

    @TableField(exist = false)
    private String createBy;

    @TableField(exist = false)
    private Date createTime;

    @TableField(exist = false)
    private String updateBy;

    @TableField(exist = false)
    private Date updateTime;

    @TableField(exist = false)
    private String remark;

    @TableField(exist = false)
    private String params;

    @TableField(exist = false)
    private String range;

    public String getRange() {
        return range;
    }

    /**
     *
     * @param range 随便填根据AQI获取
     */
    public void setRange(String range) {
        if (this.aqi > 0 && this.aqi <= 50 ){
            this.range = Constant.EXCELLENT_RANGE;
        }else if (this.aqi > 50 && this.aqi <= 100 ){
            this.range = Constant.GOOD_RANGE;
        }else if (this.aqi > 100 && this.aqi <= 150 ){
            this.range = Constant.MILD_RANGE;
        }else if (this.aqi > 150 && this.aqi <= 200 ){
            this.range = Constant.MODERATE_RANGE;
        }else if (this.aqi >200 && this.aqi <= 300){
            this.range = Constant.SEVERE_RANGE;
        }else if (this.aqi > 300){
            this.range = Constant.WORSTEST_RANGE;
        }else {
            this.range = null;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pollutant pollutant = (Pollutant) o;
        return Objects.equals(aqi, pollutant.aqi) &&
                Objects.equals(pm10, pollutant.pm10) &&
                Objects.equals(o38h, pollutant.o38h) &&
                Objects.equals(area, pollutant.area) &&
                Objects.equals(co, pollutant.co) &&
                Objects.equals(o3, pollutant.o3) &&
                Objects.equals(areaCode, pollutant.areaCode) &&
                Objects.equals(so2, pollutant.so2) &&
                Objects.equals(no2, pollutant.no2) &&
                Objects.equals(quality, pollutant.quality) &&
                Objects.equals(num, pollutant.num) &&
                Objects.equals(ct, pollutant.ct) &&
                Objects.equals(pm25, pollutant.pm25);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, primary_pollutant, aqi, pm10, o38h, area, co, o3, areaCode, so2, no2, quality, num, ct, pm25, searchValue, createBy, createTime, updateBy, updateTime, remark, params);
    }

    @Override
    public String toString() {
        return "Pollutant{" +
                "id=" + id +
                ", primary_pollutant='" + primary_pollutant + '\'' +
                ", aqi=" + aqi +
                ", pm10=" + pm10 +
                ", o38h=" + o38h +
                ", area='" + area + '\'' +
                ", co=" + co +
                ", o3=" + o3 +
                ", areaCode='" + areaCode + '\'' +
                ", so2=" + so2 +
                ", no2=" + no2 +
                ", quality='" + quality + '\'' +
                ", num=" + num +
                ", ct=" + ct +
                ", pm25=" + pm25 +
                ", range='" + range + '\'' +
                '}';
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPrimary_pollutant() {
        return primary_pollutant;
    }

    public void setPrimary_pollutant(String primary_pollutant) {
        this.primary_pollutant = primary_pollutant;
    }

    public Float getAqi() {
        return aqi;
    }

    public void setAqi(Float aqi) {
        this.aqi = aqi;
        this.setRange(null);
    }

    public Float getPm10() {
        return pm10;
    }

    public void setPm10(Float pm10) {
        this.pm10 = pm10;
    }

    public Float getO38h() {
        return o38h;
    }

    public void setO38h(Float o38h) {
        this.o38h = o38h;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public Float getCo() {
        return co;
    }

    public void setCo(Float co) {
        this.co = co;
    }

    public Float getO3() {
        return o3;
    }

    public void setO3(Float o3) {
        this.o3 = o3;
    }

    public String getAreaCode() {
        return areaCode;
    }

    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }

    public Float getSo2() {
        return so2;
    }

    public void setSo2(Float so2) {
        this.so2 = so2;
    }

    public Float getNo2() {
        return no2;
    }

    public void setNo2(Float no2) {
        this.no2 = no2;
    }

    public String getQuality() {
        return quality;
    }

    public void setQuality(String quality) {
        this.quality = quality;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public Date getCt() {
        return ct;
    }

    public void setCt(Date ct) {
        this.ct = ct;
    }

    public Float getPm25() {
        return pm25;
    }

    public void setPm25(Float pm25) {
        this.pm25 = pm25;
    }


    @Override
    public int compareTo(Object o) {
        Pollutant pollutant = (Pollutant) o;

        return this.ct.compareTo(pollutant.ct);
    }
}
